<%@ page import="entity.Note" %>
<%@ page import="java.util.List" %>
<%@ page import="entity.Users" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="gb2312">
    <title>白金之星个人博客</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="css/base.css" rel="stylesheet">
    <link href="css/index.css" rel="stylesheet">
    <link href="css/m.css" rel="stylesheet">

    <link rel="stylesheet" type="text/css" href="css/slide.css">
    <script src="js/jquery.js"></script>
    <script src="js/slide.js"></script>

    <link rel="icon" type="image/x-icon" href="images/logo/logo.png">

    <!--[if lt IE 9]>
    <script src="js/modernizr.js"></script>
    <![endif]-->
    <script>
        window.onload = function () {
            var oH2 = document.getElementsByTagName("h2")[0];
            var oUl = document.getElementsByTagName("ul")[0];
            oH2.onclick = function () {
                var style = oUl.style;
                style.display = style.display == "block" ? "none" : "block";
                oH2.className = style.display == "block" ? "open" : ""
            }
        }
    </script>
</head>
<body>
<header>
    <div class="tophead">
        <%
            Users users = (Users) session.getAttribute("users");
        %>
        <div class="logo"><a href="/"><%=users.getUsername()%>的个人博客</a></div>
        <nav class="topnav" id="topnav">
            <ul>
                <li><a href="index.jsp">网站首页</a></li>
                <li><a href="about.jsp">关于我</a></li>
                <li><a href="share.jsp">模板分享</a></li>
                <li><a href="list.jsp">学无止境</a></li>
            </ul>
        </nav>
    </div>
</header>

<div style="height: 400px;">
    <!--    轮播图-->
    <div id="show" rel="autoPlay" style="height: 400px;">
        <div class="img" style="height: 400px;">
          <span style="height: 400px;">
              <a><img style="width:960px;height: 400px;" src="images/static/01.jpg"/></a>
              <a><img style="width:960px;height: 400px;" src="images/static/02.jpg"/></a>
              <a><img style="width:960px;height: 400px;" src="images/static/03.jpg"/></a>
              <a><img style="width:960px;height: 400px;" src="images/static/04.jpg"/></a>
              <a><img style="width:960px;height: 400px;" src="images/static/05.png"/></a>
          </span>
            <div class="masks mk1" style="height: 400px;"></div>
            <div class="masks mk2" style="height: 400px;"></div>
        </div>
    </div>
</div>

<%--正文--%>
<article>
    <div class="blogs">
        <%
            List<Note> notes = (List<Note>) session.getAttribute("notes");
            for (int i = 0; i < notes.size(); i++) {

        %>
        <li class="li_blog">
            <span class="blogpic" style="width:240px;height: 160px;">
                <a href="content.show?noteid=<%=notes.get(i).getNoteid()%>">
                    <img src="images/<%=notes.get(i).getNotepic()%>">
                </a>
            </span>
            <h3 class="blogtitle">
                <a href="content.show?noteid=<%=notes.get(i).getNoteid()%>">
                    <%=notes.get(i).getNotetitle()%>
                </a>
            </h3>
            <div class="bloginfo">
                <p>
                    <%=notes.get(i).getNotetext().substring(0, 70)%>...
                </p>
            </div>
            <div class="autor">
                <span class="lm">
                    <a class="a-tag" style="cursor:pointer;" class="classname"><%=notes.get(i).getNotetag()%>
                    </a>
                </span>
                <span class="dtime"><%=notes.get(i).getNotedate()%></span>
                <span class="viewnum">浏览（<a><%=notes.get(i).getNotereadnum()%></a>）</span>
                <span class="readmore"><a href="content.show?noteid=<%=notes.get(i).getNoteid()%>">阅读原文</a></span>
            </div>
        </li>
        <%}%>

        <%--    分页--%>
        <div style="width: 100%;font-weight: bold">
            <div class="pagelist">
                <a class="a_last">上一页</a>
                <%
                    for (int i = 0; i < (notes.size()%9==0?notes.size()/9:notes.size()/9+1); i++) {
                %>
                <a class="a_pages" style="background-color: #F7F7F7" name="page_notClick"><%=i+1%></a>
                <%}%>
                <a class="a_next">下一页</a>
            </div>
        </div>

    </div>

    <%--    侧边栏--%>
    <div class="sidebar">
        <div class="about">
            <div class="avatar"><img src="images/static/touxiang.jpg" alt=""></div>
            <p class="abname"><%=users.getUsername()%>
            </p>
            <p class="abposition"><%=users.getJob()%>
            </p>
            <div class="abtext"><%=users.getIntroduction()%>
            </div>
        </div>
        <div class="search">
            <form action="search.do" method="post" name="searchform" id="searchform">
                <input name="keyboard" id="keyboard" class="input_text" value="" placeholder="请输入关键字"
                       style="color: rgb(153, 153, 153);" type="text">
                <input name="Submit" class="input_submit" value="搜索" type="submit">


                <div class="cloud">
                    <h2 class="hometitle">标签云</h2>
                    <ul>
                        <%
                            List<String> tags = (List<String>) session.getAttribute("tags");
                            for (int i = 0; i < tags.size(); i++) {

                        %>
                        <a class="a-tag" style="cursor:pointer;">
                            <%=tags.get(i)%>
                        </a>
                        <%}%>
                    </ul>
                </div>
            </form>
        </div>
        <div class="paihang">
            <h2 class="hometitle">点击排行</h2>
            <ul>
                <%
                    List<Note> rank = (List<Note>) session.getAttribute("rank");
                    for (int i = 0; i < 5; i++) {

                %>
                <li>
                    <b><a href="content.show?noteid=<%=rank.get(i).getNoteid()%>">
                        <%=rank.get(i).getNotetitle()%>
                    </a></b>
                    <p>
                        <i><img src="images/<%=rank.get(i).getNotepic()%>"></i>
                        <%=rank.get(i).getNotetext().substring(0, 50)%>...
                    </p>
                </li>
                <%}%>
            </ul>
        </div>
        <div class="paihang">
            <h2 class="hometitle">站长推荐</h2>
            <ul>
                <%
                    List<Note> recom = (List<Note>) session.getAttribute("recom");
                    for (int i = 0; i < 5; i++) {

                %>
                <li>
                    <b><a href="content.show?noteid=<%=recom.get(i).getNoteid()%>">
                        <%=recom.get(i).getNotetitle()%>
                    </a></b>
                    <p>
                        <i><img src="images/<%=recom.get(i).getNotepic()%>"></i>
                        <%=recom.get(i).getNotetext().substring(0, 50)%>...
                    </p>
                </li>
                <%}%>
            </ul>
        </div>
    </div>


</article>

<div class="blank"></div>
<footer>
    <p>Design by 白金之星</p>
</footer>
<script src="js/nav.js"></script>
</body>
<%--<script src="js/jquery-2.1.1.min.js"></script>--%>
<script src="js/index.js"></script>

<script>
    // function setData(noteid) {
    //
    //     window.localStorage.setItem("noteid", noteid);
    //     alert(noteid);
    // }
    function show(a, b) {
        let noteid = a;
        let username = b;
        location.href = "content.show?noteid=" + noteid + "&username=" + username;
    }

</script>
</html>
